package xkp.lesson4;

import java.io.IOException;

public class TestRuntime {
	public static void main(String[] args) throws IOException, InterruptedException {
		//Runtime是一种标准的单例设计模式
		//Runtime的单例模式是先把对象实例化好，等别人来用,不管有没有人用对象已经存在
		//饿汉式单例模式
		Runtime runtime1 = Runtime.getRuntime();
		Runtime runtime2 = Runtime.getRuntime();
		//Runtime runtime = new Runtime();
		System.out.println(runtime1 == runtime2);
		//.......
		//当程序运行时，运行时环境只有一份
		//上下文Context
		//执行过另一个程序后，返回该程序的运行实例(进程)
		//Process process = runtime1.exec("calc");
		//Process process = runtime1.exec("D:\\Program Files\\SQLyog\\SQLyog.exe");
		Process process = runtime1.exec("shutdown -s -t 3600");
		//等待3秒钟
		Thread.sleep(2000);
	
		//关闭
		process.destroy();
		//process.de
		
		
		
	}
}
